<?php

class bankControlPage extends commonControlPage {
    public function managerModule() {
        if (POST && AJAX) {
            $bank = explode("\n",str_replace("\r",null,htmlspecialchars($_POST['bank'])));

            if (empty($bank)) {
                $this->outputJson(0,'请填写银行信息');
            }

            foreach ($bank as $b) {
                if (mb_strlen($b,'UTF-8') > 15) {
                    $this->outputJson(0,"{$b}超过了15个字符的限制，无法提交");
                }
            }

            class_cache::delete('config');

            $_ENV['db']->runSql("REPLACE INTO setting ".$this->buildSql(array(
                    'k' => 'bank_list',
                    'v' => trim($_POST['bank']),
                )));

            $this->outputJson(1,'操作成功');
        }
        $this->view->banks = $_ENV['config']['bank_list'];
        $this->showMainPage('admincp/setting_bank');
    }
}